<?

class Configuration {
	function Configuration() {
		$this->values = include "config.php";
	}
	function get($name, $default= false) {
		if (!isset($this->values[$name])) return $default;
		return $this->values[$name];
	}
	function set($name, $value) {
		$this->values[$name] = $value;
	}
	function save() {
		$str = "<?\nreturn array(\n\t\"configuration\"=>\"true\"";
		foreach ($this->values as $n => $v) $str .= ", \n\t\"".$n."\"=>\"".$v."\"";
		$str .= " \n);\n?>";
		$handle = fopen ("config.php", "w");
		fwrite($handle, $str);
		fclose($handle);
	}
	function saveTo($path) {
		$str = "<?\nreturn array(\n\t\"configuration\"=>\"true\"";
		foreach ($this->values as $n => $v) $str .= ", \n\t\"".$n."\"=>\"".$v."\"";
		$str .= " \n);\n?>";
		$handle = fopen ($path, "w");
		fwrite($handle, $str);
		fclose($handle);
	}
}


$configuration = new Configuration();

?>